/*
*  Copyright 2019-2025 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.basic.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.basic.domain.BasicAc01;
import me.zhengjie.modules.basic.domain.BasicAc02;
import me.zhengjie.modules.basic.service.BasicAc01Service;
import me.zhengjie.modules.basic.domain.dto.BasicAc01QueryCriteria;
import lombok.RequiredArgsConstructor;

import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author ly
* @date 2025-04-24
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "人员基础信息采集")
@RequestMapping("/api/basicAc01")
public class BasicAc01Controller {

    private final BasicAc01Service basicAc01Service;

    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('basicAc01:list')")
    public void exportBasicAc01(HttpServletResponse response, BasicAc01QueryCriteria criteria) throws IOException {
        basicAc01Service.download(basicAc01Service.queryAll(criteria), response);
    }

    @GetMapping
    @ApiOperation("查询人员基础信息采集")
    @PreAuthorize("@el.check('basicAc01:list')")
    public ResponseEntity<PageResult<BasicAc01>> queryBasicAc01(BasicAc01QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(basicAc01Service.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping("/getPersonInfo")
    @ApiOperation("人员rpc")
    public ResponseEntity<List<BasicAc01>> getPersonInfo(@RequestBody BasicAc01 criteria){
        return new ResponseEntity<>(basicAc01Service.getPersonInfo(criteria),HttpStatus.OK);
    }

    @PostMapping("/getAc01")
    @ApiOperation("查询人员信息")
    public ResponseEntity<PageResult<BasicAc01>> getAc01(@RequestBody BasicAc01QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(basicAc01Service.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增人员基础信息采集")
    @ApiOperation("新增人员基础信息采集")
    @PreAuthorize("@el.check('basicAc01:add')")
    public ResponseEntity<Object> createBasicAc01(@Validated @RequestBody BasicAc01 resources) throws IOException {
        basicAc01Service.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PostMapping("/getAc01Ac02")
    @ApiOperation("查询人员信息")
    public ResponseEntity<List<Map>> getAc01Ac02(@RequestBody Map criteria){

        return new ResponseEntity<>(basicAc01Service.getAc01Ac02(criteria),HttpStatus.OK);
    }

    @PutMapping
    @Log("修改人员基础信息采集")
    @ApiOperation("修改人员基础信息采集")
    @PreAuthorize("@el.check('basicAc01:edit')")
    public ResponseEntity<Object> updateBasicAc01(@Validated @RequestBody BasicAc01 resources) throws IOException {
        basicAc01Service.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除人员基础信息采集")
    @ApiOperation("删除人员基础信息采集")
    @PreAuthorize("@el.check('basicAc01:del')")
    public ResponseEntity<Object> deleteBasicAc01(@ApiParam(value = "传ID数组[]") @RequestBody List<String> ids) {
        basicAc01Service.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
